FROM maven:3.8-jdk-11 as builder

COPY . /usr/src/app
WORKDIR /usr/src/app

RUN mvn clean package -DskipTests

RUN rm -rf /root/.m2

FROM adoptopenjdk:8-jre-hotspot

ARG JAR_FILE=chat-master.jar

COPY --from=builder /usr/src/app/target/${JAR_FILE} /app.jar

VOLUME /usr/local/logs

EXPOSE 8088

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && dpkg-reconfigure -f noninteractive tzdata

ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Duser.timezone=GMT+08", "-jar", "/app.jar", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}"]

WORKDIR /

LABEL name="gpt"